package web;

import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

//import org.apache.catalina.ContainerServlet;
//import org.apache.catalina.Wrapper;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.Controller;

import entites.Domaine;
import entites.UniteEnseignement;

import auth.service.User;
import business.domaine.IDomaineManager;
import business.unite.*;

public class ShowUniteEnseignementDashBoardController implements Controller {

	 private IUniteEnseignementManager ueManager;	
	 private IDomaineManager domaineManager;
	 protected final Log logger = LogFactory.getLog(getClass());
	 

	    public IUniteEnseignementManager getUeManager() {
		return ueManager;}


	    public void setUeManager(IUniteEnseignementManager ueManager) {
		this.ueManager = ueManager;}

		public IDomaineManager getDomaineManager() {
		return domaineManager;}


	    public void setDomaineManager(IDomaineManager domaineManager) {
		this.domaineManager = domaineManager;}
	    @Override
		public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response)
	            throws ServletException, IOException {

			// couche service
			Domaine domaine = domaineManager.selectDomaineById(3);
			
			//User user =new  User("jabass");
			User user =new  User("mamadg");
			user.setAuth(2);
			user.setCode("pers1");
			
			List<UniteEnseignement> ues = ueManager.findAllUE();
			System.out.println(ues);		

		/*	try {
				List<UniteEnseignement> ues = ueManager.showDashboardUE(user, domaine);
				System.out.println(ues);
				model.put("ues", ues);} 
			
			catch (UniteEnseignementManagerException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();}*/
			
			ModelAndView modelAndView = new ModelAndView("showUniteEnseignementDashBoard");	
			modelAndView.addObject("ues", ues);
	        logger.info("tableau de bord des unites d'enseignement"); 
	        return modelAndView; 
	    }
}
